package com.vdimitr.happycube.puzzle.utils;

/**
 * Helper class for checking that a given number is out of bounds
 * 
 * @author vasileios.dimitriadis
 * 
 */
public class RangeChecker {

	/**
	 * No need to instantiate
	 */
	private RangeChecker() {
	}

	/**
	 * Check if the given number is out of bounds
	 * 
	 * @param inclusiveLowerBound
	 *            the lower bound inclusive
	 * @param inclusiveUpperBound
	 *            the upper bound inclusive
	 * @param number
	 *            the number to check
	 * @return true if the number is lower than the inclusive lower bound or
	 *         greater than the inclusive upper bound
	 */
	public static boolean isOutOfRange(int inclusiveLowerBound,
			int inclusiveUpperBound, int number) {
		return isBelowLowerBound(inclusiveLowerBound, number)
				|| isAboveUpperBound(inclusiveUpperBound, number);
	}

	/**
	 * Check if the number is less than the inclusive lower bound
	 * 
	 * @param inclusiveLowerBound
	 *            the lower bound inclusive
	 * @param number
	 *            the number to check
	 * @return true if the number is less than the inclusive lower bound
	 */
	private static boolean isBelowLowerBound(int inclusiveLowerBound, int number) {
		return number < inclusiveLowerBound ? true : false;
	}

	/**
	 * Check if the number is greater than the inclusive upper bound
	 * 
	 * @param inclusiveUpperBound
	 *            the upper bound inclusive
	 * @param number
	 *            the number to check
	 * @return true if the number is greater than the inclusive upper bound
	 */
	private static boolean isAboveUpperBound(int inclusiveUpperBound, int number) {
		return number > inclusiveUpperBound ? true : false;
	}
}
